package com.myhome.controller;

import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.myhome.config.constant.R;
import com.myhome.domain.SysUserLog;
import com.myhome.service.SysUserLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @Author QYiXin
 * @Date 2021 10 12 16 47
 **/
@RestController
@Api(tags = "系统日志")
@RequestMapping("/sysUserLog")
public class SysUserLogController {
    @Autowired
    SysUserLogService sysUserLogService;

    @GetMapping
    @ApiOperation(value = "分页查询用户的操作记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "current", value = "当前页数"),
            @ApiImplicitParam(name = "size", value = "页面数据大小")
    })
    public R<Page<SysUserLog>> getUserLog(@ApiIgnore Page<SysUserLog> page) {
        page.addOrder(OrderItem.desc("created"));
        Page<SysUserLog> result = sysUserLogService.page(page);
        return R.ok(result);
    }
}
